home *** CD-ROM | disk | FTP | other *** search
Text File | 1989-09-21 | 6.6 KB | 305 lines | [TEXT/MPS ] |
- { *** =================================================== ***
-
- Purpose: Terminal tool's main setup procedures
- for the choose dialog. Manipulates the xbnd.r
- dialog item list being "chosen."
-
- Module : tset.p
-
- Authors: Craig Hotchkiss, Alex Kazim, Byron Han,
- Carol Lee
- Apple Computer, Inc.
- Networks & Communications
- 20525 Mariani Drive
- Cupertino, CA 95014
-
- Version : 1.0d1
-
- Date : 9.may.89
-
- History :
- 9.may.89 Creation date
-
-
- ©1989 Apple Computer, Inc. All Rights Reserved.
- This software is proprietary to Apple Computer, Inc.
- It may not be copied, in whole or in part,
- without the written consent of Apple Computer, Inc.
-
- *** =================================================== *** }
-
-
-
-
- UNIT TERMINALtset;
-
- INTERFACE
-
- USES MemTypes,
- QuickDraw,
- OSIntf,
- ToolIntf,
- PasLibIntf,
- Lists,
- CRMSerialIntf,
- CRMIntf,
- CTBUtils,
- CMIntf,
- TMIntf,
- FTIntf,
- TerminalTool,
- TermGlobalUnit;
-
-
-
- FUNCTION tsetMAIN(pSetup: TMSetupPtr; message: Integer;
- p1, p2: LongInt; VAR p3: LocalPtr): LongInt;
-
-
- IMPLEMENTATION
-
-
-
- FUNCTION TMToolPreflight(pSetup: TMSetupPtr;
- pLocal: LocalPtr): LongInt; FORWARD;
- PROCEDURE TMToolSetup(pSetup: TMSetupPtr; pLocal: LocalPtr);
- FORWARD;
- PROCEDURE TMToolItem(pSetup: TMSetupPtr; pInteger: IntegerPtr;
- pLocal: LocalPtr);
- FORWARD;
- FUNCTION TMToolFilter(pEvent: EventPtr; pInteger: IntegerPtr;
- pSetup: TMSetupPtr; pLocal: LocalPtr): Boolean;
- FORWARD;
- PROCEDURE TMToolCleanup(pLocal: LocalPtr);
- FORWARD;
-
-
-
-
- FUNCTION tsetMAIN(pSetup: TMSetupPtr; message: Integer;
- p1, p2: LongInt; VAR p3: LocalPtr): LongInt;
-
- { Returns success or failed via result and points the toolbox
- box in the direction chosen by 'message'. Message integer
- range and the pSetup parameter are defined in TerminalTool.p
- unit. pSetup param used by the toolbox for messaging with
- the choose dialog. }
-
- VAR
- theEvent: EventRecord;
- theItem: Integer;
- BEGIN
- tsetMAIN := 0;
- CASE message OF
- TMSpreflightMsg:
- tsetMAIN := TMToolPreflight(pSetup, p3);
- TMSsetupMsg:
- TMToolSetup(pSetup, p3);
- TMSitemMsg:
- BEGIN
- TMToolItem(pSetup, IntegerPtr(p1), p3);
- END;
- TMSfilterMsg:
- IF TMToolFilter(EventPtr(p1), IntegerPtr(p2),
- pSetup, p3) THEN
- tsetMAIN := 1;
- TMScleanupMsg:
- TMToolCleanup(p3);
- END; { CASE }
- END;
-
-
- FUNCTION
- TMToolPreflight(pSetup: TMSetupPtr; pLocal: LocalPtr): LongInt;
- VAR
- theID: Integer;
- theHandle: Handle;
- BEGIN
-
- { CommResource Manager used here to obtain a 'real' resource
- ID of our current tool. The result then uses DetachResource
- to free the previously used tool. }
-
- theID := CRMLocalToRealID(ClassTM, pSetup^.procID, 'DITL', 1);
- IF (theID = -1) THEN
- BEGIN
- TMToolPreflight := 0;
- Exit(TMToolPreflight);
- END;
- theHandle := GetResource('DITL', theID);
- IF (theHandle <> NIL) THEN
- DetachResource(theHandle);
- TMToolPreflight := LongInt(theHandle);
- END;
-
-
-
-
- PROCEDURE TMToolSetup(pSetup: TMSetupPtr; pLocal: LocalPtr);
- VAR
- itemType: Integer;
- itemHandle: Handle;
- itemRect: Rect;
-
- pDialog: DialogPtr;
- pConfig: TerminalPtr;
- theCurrentSetting: Integer;
- theOffset: Integer;
- theItem: Integer;
- BEGIN
- WITH pSetup^ DO
- BEGIN
- pConfig := TerminalPtr(theConfig);
- theOffset := count - 1;
- pDialog := theDialog;
- END;
-
- WITH pConfig^ DO
- BEGIN
-
- { Since my dialog controls are simple check boxes,
- their value is set accordingly. }
-
- GetDItem(pDialog, (theOffset + onlineBooleanItem),
- itemType, itemHandle, itemRect);
-
- { Here onlineBoolean refers to the field of my
- private data structure. The dialog controls are set
- accordingly. Other 2 controls set similarly. }
-
- IF onlineBoolean THEN
- SetCtlValue(ControlHandle(itemHandle), 1)
- ELSE
- SetCtlValue(ControlHandle(itemHandle), 0);
-
-
- GetDItem(pDialog, (theOffset + screenWidthItem),
- itemType, itemHandle, itemRect);
- IF screenWidth THEN
- SetCtlValue(ControlHandle(itemHandle), 1)
- ELSE
- SetCtlValue(ControlHandle(itemHandle), 0);
-
-
- GetDItem(pDialog, (theOffset + cursorStyleItem),
- itemType, itemHandle, itemRect);
- IF cursorStyle THEN
- SetCtlValue(ControlHandle(itemHandle), 1)
- ELSE
- SetCtlValue(ControlHandle(itemHandle), 0);
-
-
- END; { pConfig^ WITH }
- END;
-
-
-
- PROCEDURE TMToolItem(pSetup: TMSetupPtr; pInteger: IntegerPtr;
- pLocal: LocalPtr);
-
- { This procedure handles users actions with the dialog item
- controls. It even sets my private data structure like a good
- procedure should. }
-
- VAR
- itemNumber: Integer;
- itemType: Integer;
- itemHandle: Handle;
- itemRect: Rect;
-
- pDialog: DialogPtr;
- pConfig: TerminalPtr;
-
- theOffset: Integer;
- theItem: Integer;
- theValue: Integer;
- BEGIN
- WITH pSetup^, pLocal^ DO
- BEGIN
- pConfig := TerminalPtr(theConfig);
- theOffset := count - 1;
- theItem := pInteger^;
- GetDItem(theDialog, theItem, itemType, itemHandle, itemRect);
- theItem := pInteger^ - theOffset; { local id }
- CASE theItem OF
-
- { Each case instance below, I simply toggle the item
- values. }
-
- onlineBooleanItem:
- BEGIN
- theValue := GetCtlValue(ControlHandle(itemHandle));
- IF theValue = 1 THEN
- BEGIN
- SetCtlValue(ControlHandle(itemHandle), 0);
- pConfig^.onlineBoolean := false;
- END
- ELSE
- BEGIN
- SetCtlValue(ControlHandle(itemHandle), 1);
- pConfig^.onlineBoolean := true;
- END;
- ShowDItem (theDialog, (theOffset + onlineBooleanItem));
- END;
-
- screenWidthItem:
- BEGIN
- theValue := GetCtlValue(ControlHandle(itemHandle));
- IF theValue = 1 THEN
- BEGIN
- SetCtlValue(ControlHandle(itemHandle), 0);
- pConfig^.screenWidth := false;
- END
- ELSE
- BEGIN
- SetCtlValue(ControlHandle(itemHandle), 1);
- pConfig^.screenWidth := true;
- END;
- ShowDItem (theDialog, (theOffset + screenWidthItem));
- END;
-
- cursorStyleItem:
- BEGIN
- theValue := GetCtlValue(ControlHandle(itemHandle));
- IF theValue = 1 THEN
- BEGIN
- SetCtlValue(ControlHandle(itemHandle), 0);
- pConfig^.cursorStyle := false;
- END
- ELSE
- BEGIN
- SetCtlValue(ControlHandle(itemHandle), 1);
- pConfig^.cursorStyle := true;
- END;
- ShowDItem (theDialog, (theOffset + cursorStyleItem));
- END;
-
- END; { CASE }
- END; { WITH }
- END;
-
-
-
- FUNCTION TMToolFilter(pEvent: EventPtr; pInteger: IntegerPtr;
- pSetup: TMSetupPtr; pLocal: LocalPtr): Boolean;
-
- { This function should be used to filter user's actions and
- values. My check boxes are so simple, I always return false. }
-
- BEGIN
- TMToolFilter := false;
- END;
-
-
-
- PROCEDURE TMToolCleanup(pLocal: LocalPtr);
-
- { If I was allocating any special structures or had values
- that needed to reset, they would have been accomplished here. }
- BEGIN
- { nothing for now }
- END;
-
-
- END.
-